<?php
use yii\helpers\Url;
?>
<div style="background: #2DAD5E;text-align: center;height: 2rem;line-height: 2rem;color: #fff">

    <p>操作员登录</p>

</div>
<div style="width: 80%;margin: 0 auto">
<div style="text-align: center;margin-top: 2rem">
    <img style="width: 40%" src="/assets/img/logo.png">
</div>
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">账号</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" id="username" type="text" placeholder="请输入账号">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input" id="password" type="password" placeholder="请输入密码">
        </div>
    </div>
</div>
<br>
<a href="javascript:;" id="login" style="background: #2DAD5E" class="weui-btn weui-btn_primary">登录</a>
</div>
<script>
    $("#login").click(function(){
        var username= $("#username").val();
        var password=$("#password").val();
        if(username==''){
            alert("用户名不能为空！");
            return ;
        }
        if(password==''){
            alert("密码不能为空！");
            return ;
        }


        $.ajax({
            url:"<?=Url::to(['site/login-operator'])?>",
            data:"username="+username+"&password="+password,
            type:'post',
            dataType:'json',
            success:function(data){
                if(data.status){
                    window.location.href="<?=Url::to(['site/choose-cate'])?>";
                }else{
                    alert(data.msg);
                }
            },
            error:function(){
                alert("系统繁忙");
            }
        })
    })
</script>
